package com.asf.sofom.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.asf.sofom.domain.OTidentificacion;

@Repository(value ="tidentificacionDao")
public class JPATidentificacion implements TidentificacionDao {

	private EntityManager em = null;
	
	@PersistenceContext
	public void setEntityManager(EntityManager em){
		this.em = em;
	}	
	
	@Transactional(readOnly = true)
	@SuppressWarnings("unchecked")	
	public List<OTidentificacion> getTidentificacion() {
		TypedQuery<OTidentificacion> tq = (TypedQuery<OTidentificacion>) em.createNativeQuery("Select * from personas_tidentificacion", OTidentificacion.class);
		List<OTidentificacion> lt = tq.getResultList();			
		return lt;
	}

	public void setTidentificacion(List<OTidentificacion> identificacion) {
		em.merge(identificacion);
		
	}

}
